package com.gitee.neuray.security.file.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.text.SimpleDateFormat;
import java.util.Locale;

/**
 * @author: zhhongyu
 * @description:
 * @since: Create in 15:09 2020/1/8
 */


public class DateUtils {
    public DateUtils() {
    }

    public static String httpDate() {
        return httpDate(new Date());
    }

    public static String httpDate(Date date) {
        SimpleDateFormat greenwichDate = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
        return greenwichDate.format(date);
    }

    public static String httpDate(long millis) {
        return httpDate(new Date(millis));
    }

    public static String formatDateTime(Date date) {
        if (null == date) {
            return null;
        } else {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return format.format(date);
        }
    }
}

